/*
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2021-12-06 17:18:37
 * @LastEditTime: 2021-12-06 17:36:29
 * @LastEditors: 赵大壮
 */
import DZServiceAssess from "@/views/测评管理/service/DZServiceAssess";
import { Component, Vue, Inject } from "vue-property-decorator";
import DZServiceInves from "../../service/DZServiceInves";

@Component({
    components: {}
})
export default class Index extends Vue {

    s_inves = new DZServiceInves();

    s_assess = new DZServiceAssess();

    created() {
        this.s_inves.m_inv.id = (this.$route.query.invId as string)
        if (this.s_inves.m_inv.id) {
            this.s_inves.net_info_inv();
        }
        this.s_inves.net_list_template_base_all();
        this.s_inves.net_list_template_question_all();
        this.s_assess.net_list_assess_dic();
    }

    mounted() {

    }

    beforeDestroy() {

    }

    action_select_list_cover(file) {
        if (file.status == "ready") {
            this.s_inves.m_inv.listCoverUrl = URL.createObjectURL(file.raw);
            this.s_inves.net_upload_image(file.raw, data => {
                this.s_inves.m_inv.listCover = data;
            }, () => {
                this.s_inves.m_inv.listCoverUrl = "";
            });
        }
    }

    action_select_info_cover(file) {
        if (file.status == "ready") {
            this.s_inves.m_inv.infoCoverUrl = URL.createObjectURL(file.raw);
            this.s_inves.net_upload_image(file.raw, data => {
                this.s_inves.m_inv.infoCover = data;
            }, () => {
                this.s_inves.m_inv.infoCoverUrl = "";
            });
        }
    }

    action_add_inv() {
        if (this.s_inves.m_inv.id) {
            this.s_inves.net_edit_inv(() => {
                this.$router.back();
            })
        } else {
            this.s_inves.net_add_inv(() => {
                this.$router.back();
            })
        }
    }
}